<?php
class Recipe extends AppModel
{
	public $name = 'Recipe';
	public $hasAndBelongsToMany = array(
		'Category' => array(
			'className' => 'Category',
			'joinTable' => 'categories_recipes',
			'foreignKey' => 'recipe_id',
			'associationForeignKey' => 'category_id',
			'unique' => true,
			
			),
		'Main' => array(
			'className' => 'Main',
			'joinTable' => 'mains_recipes',
			'foreignKey' => 'recipe_id',
			'associationForeignKey' => 'main_id',
			'unique' => true,
			

			),
		);

	public $validate = array(
		    'title' => array(
	            'required' => array(
	                'rule' => 'notEmpty',
	                'message' => 'A title is required'
	            ),
	            'duplicate' => array(
	            	'rule' => 'isUnique',
	            	'message' => 'Your title already exists'
	            	),
	        ),
	        'content' => array(
	        	'required' => array(
	        		'rule' => 'notEmpty',
	        		'message' => 'The content is required'
	        		),
	        	),
	        'image' => array(
	        	'required' => array(
	        		'rule' => 'notEmpty',
	        		'message' => 'The image is required'
	        		),
	        	),
	        'template' => array(
	        	'required' => array(
	        		'rule' => 'notEmpty',
	        		'message' => 'The template is required'
	        		),
	        	),
		); // end validate


}